package com.javabasic.algorithm.sword_of_offer;

/**
 * @author xiongmin
 * @version 0.0.1
 * @description Created by work on 2021/10/14 12:17 上午
 * @see
 */
public class 山峰数组的顶部 {

    /**
     * 暴力+取巧  题目给定：数组是一个山峰数组
     * @param arr
     * @return
     */
    public int peakIndexInMountainArray(int[] arr) {
        for (int i = 1; ; i++) {
            if (arr[i] < arr[i-1]) {
                return i-1;
            }
        }
    }
}
